package com.abaaba.project2.controller.wxcontroller;

import com.abaaba.project2.bean.Coupon;
import com.abaaba.project2.bean.bo.*;
import com.abaaba.project2.bean.vo.BaseRespVo;
import com.abaaba.project2.bean.vo.wx.WxCouponListVo;
import com.abaaba.project2.bean.vo.wx.WxReceiveCouponVo;
import com.abaaba.project2.bean.vo.wx.WxSelectCouponVo;
import com.abaaba.project2.bean.vo.wx.WxUserCouponListVo;
import com.abaaba.project2.service.wx.WxCouponService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

@RestController
@RequestMapping("/wx/coupon")
public class WxCouponController {

    @Autowired
    WxCouponService wxCouponService;


    /**
     * 显示所有优惠券
     *
     * @param wxCouponListBo
     * @return
     */
    @RequestMapping("/list")
    public BaseRespVo list(WxCouponListBo wxCouponListBo) {
        WxCouponListVo wxCouponListVo = wxCouponService.wuCouponList(wxCouponListBo);
        return BaseRespVo.ok(wxCouponListVo);
    }

    /**
     * 领取优惠券
     *
     * @param wxReceiveCouponBo
     * @return
     */
    @RequestMapping("/receive")
    public WxReceiveCouponVo receive(@RequestBody WxReceiveCouponBo wxReceiveCouponBo) {
        WxReceiveCouponVo wxReceiveCouponVo = wxCouponService.wxReceiveCoupon(wxReceiveCouponBo);
        return wxReceiveCouponVo;
    }


    /**
     * 显示用户自己的优惠券列表
     *
     * @param wxUserCouponListBo
     * @return
     */
    @RequestMapping("/mylist")
    public BaseRespVo mylist(WxUserCouponListBo wxUserCouponListBo) {

        WxUserCouponListVo wxCouponListVo = wxCouponService.wxUserCouponList(wxUserCouponListBo);
        return BaseRespVo.ok(wxCouponListVo);
    }

    /**
     *兑换券的兑换
     * @param wxExchangeCouponBo
     * @return
     */
    @RequestMapping("/exchange")
    public WxReceiveCouponVo exchange(@RequestBody WxExchangeCouponBo wxExchangeCouponBo) {
        WxReceiveCouponVo wxReceiveCouponVo = wxCouponService.wxExchangeCoupon(wxExchangeCouponBo);
        return wxReceiveCouponVo;
    }

    /**
     * 下单时优惠券的选择
     * @param wxSelectCouponBo
     * @return
     */
    @RequestMapping("/selectlist")
    public BaseRespVo selectlist(WxSelectCouponBo wxSelectCouponBo){
        List wxSelectCouponVo = wxCouponService.selectCoupon(wxSelectCouponBo);
        return BaseRespVo.ok(wxSelectCouponVo);
    }

}
